<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>作业10</title>
    <script>
        /*
        10. 编写函数maxr(char) 返回字符串char中最长的连续重复字母
        比如maxr("mmmiijjjjkkkkkkssptr") 返回"kkkkkk"
        */
        var a = [1,,2,3];
        a.length

        function maxr(char) {
            var sum = 1;
            var maxLength = 1;
            var tmp = "";
            var maxChar = "";
            for(var i=0; i<char.length; i++) {
                if (char.charAt(i) == char.charAt(i+1)) {
                    sum++ ;
                    tmp = tmp+char.charAt(i);
                }else{
                    tmp = tmp+char.charAt(i);
                    if(maxLength < sum){
                        maxLength = sum;
                        maxChar = tmp;
                    }
                    tmp = "";
                    sum = 1;
                }
            }
            return maxChar;
        }

        console.log(maxr("mmmiijjjjkkkkkkssptr"))

    </script>
</head>
<body>
    
</body>
</html>